<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>图书后台管理系统</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="../Xadmin/css/font.css">
    <link rel="stylesheet" href="../Xadmin/css/xadmin.css">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
    <script src="../layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../Xadmin/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script>
        var is_remember = false;
    </script>
</head>
<body>
<div class="layui-form-item">
    <label class="layui-form-label">题库试卷类型：</label>
    <div class="layui-input-block">
        <input class="layui-input" name="category" id="category" autocomplete="off" style="width: 30rem;" />
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">题目内容：</label>
    <div class="layui-input-block">
        <input class="layui-input" name="Ttext" id="Ttext" autocomplete="off" style="width: 30rem;" />
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">选项1：</label>
    <div class="layui-input-block">
        <input class="layui-input" name="choice1" id="choice1" autocomplete="off" style="width: 30rem;"/>
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">选项2：</label>
    <div class="layui-input-block">
        <input class="layui-input" name="choice2" id="choice2" autocomplete="off" style="width: 30rem;"/>
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">选项3：</label>
    <div class="layui-input-block">
        <input class="layui-input" name="choice3" id="choice3" autocomplete="off" style="width: 30rem;"/>
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">选项4：</label>
    <div class="layui-input-block">
        <input class="layui-input" name="choice4" id="choice4" autocomplete="off" style="width: 30rem;"/>
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">正确答案：</label>
    <div class="layui-input-block">
        <input class="layui-input" name="correct" id="correct" autocomplete="off" style="width: 30rem;" onkeyup="this.value=this.value.replace(/\D/g,'')" + onafterpaste="this.value=this.value.replace(/\D/g,'')">
    </div>
</div>
<button class="layui-btn" style="margin-left:20rem" onclick="addSubject()">添加</button>
</body>
<script>
    layui.use('layer', function () {
        console.log('layer导入成功！')
    })
    function addSubject(){
        $.ajax({
            url:"http://127.0.0.1:8081/Subject/Subject",
            method:"post",
            data:{
                category:$("#category").val(),
                type:$("#category").val(),
                Ttext:$("#Ttext").val(),
                choice1:$("#choice1").val(),
                choice2:$("#choice2").val(),
                choice3:$("#choice3").val(),
                choice4:$("#choice4").val(),
                correct:$("#correct").val()
            },
            success: function (res) {
                var object = JSON.parse(res)
                if (object.code === '0') {
                    layer.alert("添加成功")
                } else {
                    layer.alert("添加失败")
                }
                reload()
            }
            })
    }

</script>
</html>